<template>
  <!--短信配置-->
  <div class="search">
    <f-form ref="form2" form-key="sms">


      <f-form-item label="开启短信" name="enable" type="switch" :value="SMS_CONFIG.enable"/>
      <f-form-item label="accessKey" name="accessKey" :value="SMS_CONFIG.accessKey"/>
      <f-form-item label="accessSecret" name="accessSecret" :value="SMS_CONFIG.accessSecret"/>
      <f-form-item label="验证码模板" name="smsTplCode" :value="SMS_CONFIG.smsTplCode"/>
      <f-form-item label="签名" name="signName" :value="SMS_CONFIG.signName"/>
      <f-form-item label="手机号加密" name="encryption" type="switch" :value="SMS_CONFIG.encryption"/>
      <f-form-item label="自定义验证码处理器" name="smsCodeHander" :value="SMS_CONFIG.smsCodeHander" width="300px"/>

    </f-form>
  </div>
</template>

<script>
  export default {
    name: 'smsForm',
    props: {},
    data () {
      return {
        isAdd: true,
        SMS_CONFIG: {
          accessKey: '',
          accessSecret: '',
          signName: '',
          smsTplCode: '',
          encryption: '',
          smsCodeHander: ''
        }
      }
    },
    methods: {
      getOss () {
        this.http.get(this, {
          url: this.api.config.get,
          data: {
            configType: 'sms'
          },
          success: function (me, data) {
            if (data.SMS_CONFIG) {
              me.SMS_CONFIG = JSON.parse(data.SMS_CONFIG)
            }
          }
        })
      },
      setData () {
        this.$refs.form2.resetFields()
        this.getOss()
      },
      handleSubmit () {
        this.$refs.form2.getForm().validateFields((valid, values) => {
            if (!valid) {
              console.log(values)
              this.http.post(this, {
                url: this.api.config.smsSave,
                data: values,
                success: function (me) {

                }
              })
            }
          }
        )
      }
    },
    computed: {
      linkSolt: function () {
        return {
          name: 'http',
          slotName: 'addonBefore',
          value: 'http://',
          width: 90,
          data: [{ label: 'http://', value: 'http://' }, { label: 'https://', value: 'https://' }]
        }
      }
    },
    created () {
      this.getOss()
    },
    components: {}
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
